<template>
  <!-- 用户权限 -->
  <div class="main-container" v-loading="loading">
    <div class="box-container">
      <div class="yhqx-left">
        <div class="card-container">
          <a-tabs default-active-key="1" class="tabsHeader">
            <a-tab-pane key="1" :tab="personInfo.dwmc">
              <new-tree-select
                :data="dwList"
                :defaultProps="defaultProps"
                style="width: 72%; margin: 12px 0"
                :expand-on-click-node="true"
                node-key="dwbm"
                ref="treeselected"
                v-model="Tdwbm"
                placeholder="请选择您的单位"
                :clearable="false"
                :default-expanded-keys="expandedKey"
              ></new-tree-select>
              <div style="height: 45px">
                <a-input-search
                  v-model="searchVal"
                  style="width: 300px"
                  @change="onDwSearch"
                  allow-clear
                  @search="onDwSearch"
                />
              </div>
              <a-collapse v-model="activeKey" v-if="yhqlLists.length > 0">
                <a-collapse-panel
                  v-for="item in yhqlLists[0].children"
                  :key="item.id"
                  :header="item.mc"
                  v-show="!item.show"
                >
                  <div class="box">
                    <div class="collapse-item" v-for="item1 in item.children" :key="item1.id">
                      <!-- arr1(角色) arr2(人员)) -->
                      <!-- panel-title2,btn-item1:禁用 -->
                      <template>
                        <div
                          v-if="!item1.show"
                          :class="[
                          item1.check ? 'panel-title1' : 'panel-title',
                          arr2.length <= 0 ? '' : 'panel-title2'
                        ]"
                        >
                          <div
                            style="margin-bottom: 10px; cursor: pointer"
                            @click="item1Click(item1)"
                          >{{ item1.mc }}</div>
                        </div>
                      </template>

                      <template>
                        <div
                          v-if="!item2.show"
                          class="btn-item"
                          :class="{
                          btn_active: item2.check,
                          'btn-item1': !arr1.length <= 0
                        }"
                          v-for="item2 in item1.children"
                          :key="item2.id"
                          style="margin: 0 10px 10px 0"
                          @click="item2Click(item2)"
                        >
                          <span>{{ item2.mc }}</span>
                        </div>
                      </template>
                    </div>
                  </div>
                </a-collapse-panel>
              </a-collapse>
            </a-tab-pane>
          </a-tabs>
        </div>
      </div>
      <div class="right">
        <div class="top" style="position: relative">
          <div class="card-container">
            <a-tabs hide-add type="editable-card">
              <a-tab-pane key="1" tab="授权对象" style="overflow: auto">
                <div
                  class="btn-item"
                  style="margin: 0 10px 10px 0"
                  v-for="(item, index) in sqdxLists"
                  :key="index"
                >{{ item.mc }}</div>
              </a-tab-pane>
            </a-tabs>
          </div>
          <div
            class="btn-group-item btn-group-delete-item single-btn"
            style="position: absolute; right: 10px; top: 6px"
            @click="qingKong"
          >
            <IconFont type="swx-icon-shanchu" />清空
          </div>
        </div>
        <div class="bottom">
          <div class="card-container">
            <a-tabs hide-add type="editable-card" v-model="activeTabKey">
              <a-tab-pane key="1" tab="功能授权">
                <div style="height: 45px">
                  <div style="float: left">
                    <a-input-search
                      style="width: 300px"
                      @change="onSearchTable"
                      placeholder="请输入功能名称"
                      allowClear
                    />
                  </div>
                  <div class="btn-group" style="float: right">
                    <div
                      :class="[
                      sqdxLists.length > 0 ? '' : 'disabled-btn',
                      'btn-group-item'
                    ]"
                      style="margin-right: 6px"
                      @click="addGn"
                    >
                      <IconFont type="swx-icon-tianjia" />添加功能
                    </div>
                    <div
                      :class="[
                      sqdxLists.length == 1 ? '' : 'disabled-btn',
                      'btn-group-item'
                    ]"
                      style="margin-right: 6px"
                      @click="copyGn"
                    >
                      <IconFont type="swx-icon-fuzhi" />复制功能权限
                    </div>
                    <div
                      :class="[
                      sqdxLists.length > 0 ? '' : 'disabled-btn',
                      'btn-group-item',
                      'btn-group-delete-item'
                    ]"
                      @click="moveSq"
                    >
                      <IconFont type="swx-icon-shanchu" />移除授权
                    </div>
                  </div>
                </div>

                <!-- 功能table树形列表 -->
                <div style="margin-bottom: 40px; height: 100%">
                  <a-table
                    :columns="gNcolumns"
                    class="sxlb"
                    :data-source="lists"
                    :row-selection="{
                    ...GNrowSelection,
                    onChange: onGnSelectChange,
                    selectedRowKeys: GNselectedRowKeys
                  }"
                    :pagination="false"
                  >
                    <template slot="action" slot-scope="text, record">
                      <a slot="action" href="javascript:;" style="margin-right: 4px">
                        <span
                          class="empty-btn"
                          v-if="!text.disabled && text.qxbjqmc != null"
                          @click="bjqxBtn(text)"
                        >
                          <IconFont type="swx-icon-tianjia" />编辑权限
                        </span>
                      </a>
                      <a slot="action" href="javascript:;">
                        <span
                          class="empty-btn"
                          v-if="!text.disabled && text.gnly == '自身功能'"
                          @click="ycsq(text)"
                        >
                          <IconFont type="swx-icon-shanchu" />移除授权
                        </span>
                      </a>
                    </template>
                  </a-table>
                </div>
              </a-tab-pane>

              <a-tab-pane key="2" tab="首页授权" v-if="false">
                <div style="height: 45px">
                  <div style="float: left">
                    <a-input-search style="width: 300px" placeholder="请输入组件名称" allowClear />
                  </div>
                  <div class="btn-group" style="float: right">
                    <div
                      :class="[
                      sqdxLists.length > 0 ? '' : 'disabled-btn',
                      'btn-group-item'
                    ]"
                      style="margin-right: 6px"
                      @click="addZj"
                    >
                      <IconFont type="swx-icon-tianjia" />添加组件
                    </div>
                    <div
                      :class="[
                      sqdxLists.length == 1 ? '' : 'disabled-btn',
                      'btn-group-item'
                    ]"
                      style="margin-right: 6px"
                      @click="copyGn"
                    >
                      <IconFont type="swx-icon-fuzhi" />复制组件权限
                    </div>
                    <div
                      :class="[
                      sqdxLists.length > 0 ? '' : 'disabled-btn',
                      'btn-group-item',
                      'btn-group-delete-item'
                    ]"
                      @click="moveSq"
                    >
                      <IconFont type="swx-icon-shanchu" />移除授权
                    </div>
                  </div>
                </div>

                <!-- 首页授权table树形列表 -->
                <div style="margin-bottom: 40px; height: 100%">
                  <a-table
                    :columns="sysqColumns"
                    class="sxlb"
                    :data-source="sylists"
                    :row-selection="{
                    ...SYrowSelection,
                    onChange: onSySelectChange,
                    selectedRowKeys: SYselectedRowKeys
                  }"
                    :pagination="false"
                  >
                    <template slot="action" slot-scope="text, record">
                      <a slot="action" href="javascript:;" style="margin-right: 4px">
                        <span
                          class="empty-btn"
                          v-if="!text.disabled && text.zjbjqmc != null"
                          @click="bjqxBtn(text)"
                        >
                          <IconFont type="swx-icon-bianjiiconkaobei14" />编辑权限
                        </span>
                      </a>
                      <a slot="action" href="javascript:;">
                        <span
                          class="empty-btn"
                          v-if="!text.check && text.zhly == '自身组件'"
                          @click="ycsqSytable(text)"
                        >
                          <IconFont type="swx-icon-shanchu" />移除授权
                        </span>
                      </a>
                    </template>
                  </a-table>
                </div>
              </a-tab-pane>
            </a-tabs>
          </div>
        </div>
      </div>
    </div>

    <!-- 添加功能 -->
    <a-modal
      v-model="showAdd"
      title="添加功能"
      @ok="addGnQdan"
      class="yhqx-dialog"
      @cancel="close"
      centered
    >
      <div class="dialog">
        <div class="dialogheader">
          对象:
          {{ sqdxLists && sqdxLists.map(item => item.mc).toString() }}
        </div>
        <div class="dialogcontent">
          <div class="left">
            <a-input-search
              style="margin-bottom: 8px"
              placeholder="输入关键字查询"
              @change="onChange"
              allowClear
            />
            <a-tree
              v-if="addGnTree.length > 0"
              :tree-data="addGnTree"
              :replace-fields="replaceFields"
              checkable
              :checkedKeys="defaultCheckedKeys"
              @check="clickCheckGn"
              blockNode
            ></a-tree>
          </div>
          <div class="right">
            <div class="tab-box">
              <a-tabs default-active-key="1">
                <a-tab-pane key="1" tab="已选择功能">
                  <div class="jcbg" style="margin-bottom: 40px">
                    <a-table :columns="columns" :data-source="data" :pagination="false"></a-table>
                  </div>
                </a-tab-pane>
              </a-tabs>
            </div>
          </div>
        </div>
      </div>
    </a-modal>

    <!-- 添加组件 -->
    <a-modal
      v-model="showAddZj"
      title="添加组件"
      @ok="addZjQdan"
      class="yhqx-dialog"
      @cancel="close"
      centered
    >
      <div class="dialog">
        <div class="dialogheader">
          对象:
          {{ sqdxLists && sqdxLists.map(item => item.mc).toString() }}
        </div>
        <div class="dialogcontent">
          <div class="left">
            <a-input-search
              style="margin-bottom: 8px"
              placeholder="输入关键字查询"
              @change="onChange"
              allowClear
            />
            <a-tree
              v-if="addZjTree.length > 0"
              :tree-data="addZjTree"
              :replace-fields="replaceFields"
              checkable
              :checkedKeys="CheckedKeysZj"
              @check="clickCheckZj"
              blockNode
            ></a-tree>
          </div>
          <div class="right">
            <div class="tab-box">
              <a-tabs default-active-key="1">
                <a-tab-pane key="1" tab="已选择功能">
                  <div class="jcbg" style="margin-bottom: 40px">
                    <a-table :columns="columns" :data-source="data" :pagination="false"></a-table>
                  </div>
                </a-tab-pane>
              </a-tabs>
            </div>
          </div>
        </div>
      </div>
    </a-modal>

    <!--复制功能权限  -->
    <a-modal v-model="copyGnshow" title="复制功能权限" @ok="copyGnQdan" class="yhqx-dialog2" centered>
      <div class="dialog">
        <div class="dialogheader">{{ dialogheaderGn }}</div>
        <div class="dialogcontent">
          <div class="left">
            <div style="height: 45px">
              <a-input-search style="width: 300px" @change="onDwSearch1" />
            </div>
            <a-collapse v-model="activeKey1" v-if="yhqlListsDia.length > 0">
              <a-collapse-panel
                v-for="(item, index) in yhqlListsDia[0].children"
                :key="item.id"
                :header="item.mc"
                v-show="!item.show"
              >
                <div class="box">
                  <div
                    class="collapse-item"
                    v-for="(item1, index1) in item.children"
                    :key="item.id"
                  >
                    <template>
                      <div
                        v-if="!item1.show"
                        :class="[
                          item1.check ? 'panel-title1' : 'panel-title',
                          arr2Dia.length <= 0 ? '' : 'panel-title2'
                        ]"
                      >
                        <div
                          style="margin-bottom: 10px; cursor: pointer"
                          @click="item1DiaClick(item1)"
                        >{{ item1.mc }}</div>
                      </div>
                    </template>

                    <template>
                      <div
                        @click="item2DiaClick(item2)"
                        v-if="!item2.show"
                        class="btn-item"
                        :class="{
                          btn_active: item2.check,
                          'btn-item1': !arr1Dia.length <= 0
                        }"
                        v-for="(item2, index2) in item1.children"
                        :key="item2.id"
                        style="margin: 0 10px 10px 0"
                      >
                        <span>{{ item2.mc }}</span>
                      </div>
                    </template>
                  </div>
                </div>
              </a-collapse-panel>
            </a-collapse>
          </div>
          <div class="right">
            <div class="tab-box">
              <a-tabs default-active-key="1">
                <a-tab-pane key="1" tab="已选择对象">
                  <div class="jcbg" style="margin-bottom: 40px">
                    <div
                      class="btn-item"
                      style="margin: 0 10px 10px 0"
                      v-for="(item, index) in sqdxListsDia"
                      :key="index"
                    >{{ item.mc }}</div>
                  </div>
                </a-tab-pane>
              </a-tabs>
            </div>
          </div>
        </div>
      </div>
    </a-modal>

    <!-- 编辑权限 -->
    <a-modal
      :bodyStyle="{
        padding: 0
      }"
      v-model="bjqxDia"
      title="编辑权限"
      class="yhqx-dialog"
      :footer="null"
      centered
    >
      <div v-if="qxbjqLiaContent && qxbjqLiaContent.qxbjqdz.indexOf('http') != -1">
        <iframe :src="qxbjqLiaContent.qxbjqdz" frameborder="0" style="width: 100%; height: 600px"></iframe>
      </div>
      <div v-else style="width: 100%; height: 600px">
        <component :is="DynamicComponent"></component>
      </div>
    </a-modal>
  </div>
</template>

<script>
import service from './api/api'
const gNcolumns = [
  {
    title: '功能名称',
    dataIndex: 'gnmc'
  },
  {
    title: '权限编辑器名称',
    dataIndex: 'qxbjqmc'
  },
  {
    title: '功能来源',
    dataIndex: 'gnly'
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]
// 首页授权
const sysqColumns = [
  {
    title: '组件名称',
    dataIndex: 'mc'
  },
  {
    title: '权限编辑器名称',
    dataIndex: 'zjbjqmc'
  },
  {
    title: '组件来源',
    dataIndex: 'zhly'
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]

const columns = [
  {
    title: '功能分类',
    dataIndex: 'gnfl'
  },
  {
    title: '功能名称',
    dataIndex: 'gnmc'
  }
]
import vuex from 'vuex'
const logininfo = vuex.createNamespacedHelpers('login')
const yhqxinfo = vuex.createNamespacedHelpers('yhqx')
import newTreeSelect from './components/systemTreeSelect.vue'

export default {
  data() {
    return {
      dwList: [],
      Tdwbm: '',
      defaultProps: {
        children: 'children',
        label: 'dwmc'
      },
      expandedKey: [],
      loading: false,
      searchVal: '',
      activeKey: [],
      activeTabKey: '1',
      activeKey1: [],
      bjqxDia: false,
      qxbjqLiaContent: {
        qxbjqdz: ''
      },
      data: [], //复选框选中  弹框右边展示的数据
      columns,
      expandedKeys: [],
      searchValue: '',
      autoExpandParent: true,
      selectedKeys: [],
      gNcolumns,
      sysqColumns, //首页授权
      checkedKeys: ['0-1'],
      checkFlag: false,
      //
      sqdxLists: [], //授权对象
      arr1: [], //逻辑判断 控制样式
      arr2: [], //逻辑判断
      sqdxListsDia: [],
      arr1Dia: [], //逻辑判断 控制样式
      arr2Dia: [], //逻辑判断
      lists: [], //table表格
      lists1: [], //table表格
      showAdd: false, //添加功能弹框显示
      gData: [],
      replaceFields: {
        children: 'children',
        title: 'mc',
        key: 'bm'
      },
      yhqlLists: [],
      yhqlListsDia: [],
      yhqlListsFilter: [],
      addGnTree: [],
      addGnTree1: [], //保存临时的值
      defaultCheckedKeys: [], //功能选中节点
      CheckedKeysZj: [], //组件选中节点
      selectIds: [], //树选中的节点
      copyGnshow: false,
      selectedRows: [], //功能复选框选择的节点
      sylists: [],
      showAddZj: false,
      addZjTree: [],
      DynamicComponent: '',
      dialogheaderGn: '',
      flag: true,
      GNselectedRowKeys: [], // 功能选中节点
      SYselectedRowKeys: [], //首页选中节点
      SYselectedRows: [], //首页复选框选择的节点
      qingKongFlag: false
    }
  },
  async created() {
    await service.zzjg
      .getDwbm({
        dwbm: this.personInfo.dwbm
      })
      .then(res => {
        if (res.code == 0) {
          this.dwList = this.$getTreeData(res.data, 'dwbm', 'fdwbm')
          this.Tdwbm = this.personInfo.dwbm
          this.expandedKey = [res.data[0].dwbm]
          this.getTreeList()
        }
      })
  },
  watch: {
    Tdwbm: {
      deep: true, //深度监听
      handler(newVal, oldVal) {
        this.getTreeList()
      }
    }
  },
  methods: {
    ...yhqxinfo.mapMutations(['CHANGEMIDETYPE']),
    ...logininfo.mapMutations(['CHANGEINFO']),
    // 功能选中权限
    onGnSelectChange(selectedRowKeys, selectedRows) {
      this.GNselectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },

    // 首页选中权限
    onSySelectChange(selectedRowKeys, selectedRows) {
      this.SYselectedRowKeys = selectedRowKeys
      this.SYselectedRows = selectedRows
    },
    // 首页选中权限
    close() {
      this.data = []
      this.selectIds = []
    },
    // 移除授权
    ycsq(text) {
      this.$confirm('此操作将永久移除该权限, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          let data = null
          switch (this.sqdxLists[0].level) {
            case '3':
              data = {
                dwbm: this.Tdwbm,
                gnList: [text.gnbm],
                zhxgrbm: this.personInfo.rybm,
                zhxgrmc: this.personInfo.mc,
                jsList: this.sqdxLists.map(item => {
                  return {
                    bmbm: item.params.bmbm,
                    dwbm: item.params.dwbm,
                    jsbm: item.params.jsbm
                  }
                })
              }
              service.yhqx.deleteJsgnfp(data).then(res => {
                // console.log(res);
                if (res.code == 0) {
                  res.data && this.CHANGEINFO(res.data)
                  this.$message.success('移除成功')
                }
                this.getRoleTable()
              })
              break
            case '4':
              data = {
                dwbm: this.Tdwbm,
                gnList: [text.gnbm],
                zhxgrbm: this.personInfo.rybm,
                zhxgrmc: this.personInfo.mc,
                ryList: this.sqdxLists.map(item => {
                  return {
                    rybm: item.params.rybm,
                    zzdwbm: item.params.zzdwbm,
                    bmbm: item.params.bmbm
                  }
                })
              }
              service.yhqx.deleteRygnfp(data).then(res => {
                if (res.code == 0) {
                  res.data && this.CHANGEINFO(res.data)
                  this.$message.success('移除成功')
                }
                this.getRyTable()
              })
              break
          }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          })
        })
    },
    // 点击角色
    item1Click(item1) {
      if (this.arr2.length) {
        return false
      }
      // 第一次选中，第二次取消
      item1.check = !item1.check
      // 多选及删除
      if (item1.check) {
        this.sqdxLists.push(item1)
        this.arr1.push(item1.id)
      } else {
        //  筛选出该对象的索引
        let index = null
        for (let inx = 0; inx < this.sqdxLists.length; inx++) {
          if (this.sqdxLists[inx].id == item1.id) {
            index = inx
          }
        }
        let i = this.arr1.indexOf(item1.id)
        if (index >= 0) {
          this.sqdxLists.splice(index, 1)
        }
        if (i >= 0) {
          this.arr1.splice(i, 1)
        }
      }
      // 点击角色发送请求 列表
      if (this.sqdxLists.length > 0) {
        this.getRoleTable()
        this.getRoleSyTable()
      } else {
        this.lists = []
        this.sylists = []
      }
    },
    // 点击人员
    item2Click(item2) {
      if (this.arr1.length) {
        return false
      }
      item2.check = !item2.check
      if (item2.check) {
        this.sqdxLists.push(item2)
        this.arr2.push(item2.id)
      } else {
        // let index = this.sqdxLists.indexOf(item2);
        //  筛选出该对象的索引
        let index = null
        for (let inx = 0; inx < this.sqdxLists.length; inx++) {
          if (this.sqdxLists[inx].id == item2.id) {
            index = inx
          }
        }
        let i = this.arr2.indexOf(item2.id)
        if (index >= 0) {
          this.sqdxLists.splice(index, 1)
        }
        if (i >= 0) {
          this.arr2.splice(i, 1)
        }
      }
      if (this.sqdxLists.length > 0) {
        this.getRyTable()
        this.getRySyTable()
      } else {
        this.lists = []
        this.sylists = []
      }
    },
    // 弹框点击角色
    item1DiaClick(item1) {
      if (this.arr2Dia.length) {
        return false
      }
      // 第一次选中，第二次取消
      item1.check = !item1.check
      // 多选及删除
      if (item1.check) {
        this.sqdxListsDia.push(item1)
        this.arr1Dia.push(item1.id)
      } else {
        let index = null
        for (let inx = 0; inx < this.sqdxListsDia.length; inx++) {
          if (this.sqdxListsDia[inx].id == item1.id) {
            index = inx
          }
        }
        let i = this.arr1Dia.indexOf(item1.id)
        if (index >= 0) {
          this.sqdxListsDia.splice(index, 1)
        }
        if (i >= 0) {
          this.arr1Dia.splice(i, 1)
        }
      }
    },
    // 弹框点击人员
    item2DiaClick(item2) {
      if (this.arr1Dia.length) {
        return false
      }
      item2.check = !item2.check
      if (item2.check) {
        this.sqdxListsDia.push(item2)
        this.arr2Dia.push(item2.id)
      } else {
        let index = null
        for (let inx = 0; inx < this.sqdxListsDia.length; inx++) {
          if (this.sqdxListsDia[inx].id == item2.id) {
            index = inx
          }
        }
        let i = this.arr2Dia.indexOf(item2.id)
        if (index >= 0) {
          this.sqdxListsDia.splice(index, 1)
        }
        if (i >= 0) {
          this.arr2Dia.splice(i, 1)
        }
      }
    },
    //单位搜索
    onDwSearch() {
      let val = this.searchVal
      this.activeKey = []
      // 保存一个临时的值 用于前端筛选
      const SearchData = JSON.parse(JSON.stringify(this.yhqlListsFilter))

      // 如果没有值 默认展开第一项
      if (!val) {
        this.activeKey = [SearchData[0].children[0].id]
        let arrID = this.sqdxLists.map(item => item.id)
        const diGui = (m, arrID) => {
          for (let item of m) {
            if (arrID.includes(item.id)) {
              item.check = true
              item.show = false
            } else if (item.children && item.children.length > 0) {
              diGui(item.children, arrID)
            }
          }
        }
        diGui(SearchData, arrID)
      } else {
        // 遍历这个数组
        SearchData[0].children.forEach((item, index) => {
          // 如果有值展开所有的折叠菜单
          this.activeKey.push(item.id)
          this.getSearch(val, item, item)
        })
      }
      this.yhqlLists = SearchData
      this.qingKongFlag = false
    },
    getSearch(val, item, itemA, param = true) {
      if (param) {
        itemA.show = true
      }
      const _this = this
      if (item.children && item.children.length > 0) {
        for (let i = 0; i < item.children.length; i++) {
          const storeA = item.children[i]
          // 如果匹配到数据
          if (this.$spellSearch.match(storeA.mc, val)) {
            // 如果选择的人 角色也应当显示
            itemA.show = false
            item.show = false
            storeA.show = false
            _this.sqdxLists.forEach(item => {
              if (storeA.id == item.id) {
                storeA.check = true
              }
            })
          } else {
            storeA.show = true
          }
          this.getSearch(val, storeA, itemA, false)
        }
      }
    },
    // 从组织机构跳转过来得
    onDwSearch2(val) {
      this.activeKey = []
      // 保存一个临时的值 用于前端筛选
      const SearchData = JSON.parse(JSON.stringify(this.yhqlListsFilter))
      // 如果没有值 默认展开第一项
      if (!val) {
        this.activeKey = [SearchData[0].children[0].id]
      } else {
        // 遍历这个数组
        if (this.nodeMessegeVuex.level == 3) {
          this.activeKey.push(this.nodeMessegeVuex.departmentId)
        }
        if (this.nodeMessegeVuex.level == 4) {
          this.activeKey.push(this.nodeMessegeVuex.departmentId)
        }
        SearchData[0].children.forEach((item, index) => {
          this.getSearch2(val, item)
        })
      }
      this.yhqlLists = SearchData
    },
    getSearch2(val, item) {
      if (item.children && item.children.length > 0) {
        for (let i = 0; i < item.children.length; i++) {
          const storeA = item.children[i]
          // 如果匹配到数据
          if (this.$spellSearch.match(storeA.id, val)) {
            item.show = false
            storeA.show = false
            if (storeA.level == '3') {
              this.item1Click(storeA)
              item.check = true
              return
            }
            if (storeA.level == '4') {
              this.item2Click(storeA)
              storeA.check = true
            }
          } else {
            storeA.show = false
          }
          if (storeA.id) this.getSearch2(val, storeA)
        }
      }
    },
    //复制功能权限单位搜索
    onDwSearch1(e) {
      let val = e.target.value
      this.activeKey1 = []
      const SearchData = JSON.parse(JSON.stringify(this.yhqlListsDiaFilter))
      if (!val) {
        this.activeKey1 = [SearchData[0].children[0].id]
        let arrID = this.sqdxListsDia.map(item => item.id)
        const diGui = (m, arrID) => {
          for (let item of m) {
            if (arrID.includes(item.id)) {
              item.check = true
              item.show = false
            } else if (item.children && item.children.length > 0) {
              diGui(item.children, arrID)
            }
          }
        }
        diGui(this.yhqlListsFilter, arrID)
      } else {
        SearchData[0].children.forEach((item, index) => {
          this.activeKey1.push(item.id)
          this.getSearch1(val, item, item)
        })
      }
      this.yhqlListsDia = SearchData
    },
    getSearch1(val, item, itemA, param = true) {
      if (param) {
        itemA.show = true
      }
      if (item.children && item.children.length > 0) {
        for (let i = 0; i < item.children.length; i++) {
          const storeA = item.children[i]
          if (this.$spellSearch.match(storeA.mc, val)) {
            itemA.show = false
            item.show = false
            // 向空数组中添加数据
            storeA.show = false
            this.sqdxListsDia.forEach(item => {
              if (storeA.id == item.id) {
                storeA.check = true
              }
            })
          } else {
            storeA.show = true
          }
          if (storeA.id) this.getSearch1(val, storeA, itemA, false)
        }
      }
    },
    onSearchTable(e) {
      if (this.sqdxLists.length > 0) {
        const value = e.target.value
        if (value) {
          const tree = JSON.parse(JSON.stringify(this.lists))
          this.lists = this.filter1(tree, value)
        } else {
          this.lists = this.lists1
        }
      }
    },
    onChange(e) {
      const value = e.target.value
      if (value) {
        const tree = JSON.parse(JSON.stringify(this.addGnTree))
        this.addGnTree = this.filter(tree, value)
      } else {
        this.addGnTree = this.addGnTree1
      }
    },
    // nodebuggers就是树形的最原始数据，query就是关键字，最后会返回满足条件的节点数组
    filter(nodes, query) {
      // 条件就是节点的title过滤关键字
      let predicate = function (node) {
        if (node.mc.indexOf(query) > -1) {
          return true
        } else {
          return false
        }
      }
      if (!(nodes && nodes.length)) {
        return []
      }
      let newChildren = []
      for (let node of nodes) {
        // 以下两个条件任何一个成立，当前节点都应该加入到新子节点集中
        // 1. 子孙节点中存在符合条件的，即 subs 数组中有值
        // 2. 自己本身符合条件
        let subs = this.filter(node.children, query)
        if (predicate(node)) {
          newChildren.push(node)
        } else if (subs && subs.length) {
          node.children = subs
          newChildren.push(node)
        }

        // 以下只需要考虑自身的节点满足条件即可,不用带上父节点
        // if (predicate(node)) {
        //     newChildren.push(node);
        //     node.children = this.filter(node.children, query);
        // } else {
        //     newChildren.push(...this.filter(node.children, query));
        // }
      }
      return newChildren.length ? newChildren : []
    },
    // table nodes就是树形的最原始数据，query就是关键字，最后会返回满足条件的节点数组
    filter1(nodes, query) {
      // 条件就是节点的title过滤关键字
      let predicate = function (node) {
        if (node.gnmc.indexOf(query) > -1) {
          return true
        } else {
          return false
        }
      }
      if (!(nodes && nodes.length)) {
        return []
      }
      let newChildren = []
      for (let node of nodes) {
        // 以下两个条件任何一个成立，当前节点都应该加入到新子节点集中
        // 1. 子孙节点中存在符合条件的，即 subs 数组中有值
        // 2. 自己本身符合条件
        let subs = this.filter1(node.children, query)
        if (predicate(node)) {
          newChildren.push(node)
        } else if (subs && subs.length) {
          node.children = subs
          newChildren.push(node)
        }

        // 以下只需要考虑自身的节点满足条件即可,不用带上父节点
        // if (predicate(node)) {
        //     newChildren.push(node);
        //     node.children = this.filter(node.children, query);
        // } else {
        //     newChildren.push(...this.filter(node.children, query));
        // }
      }
      return newChildren.length ? newChildren : []
    },
    // 清空
    qingKong() {
      this.qingKongFlag = true
      // 清除授权对象
      this.sqdxLists = []
      // 用户操作
      this.flag = false
      // 功能授权
      this.lists = []
      // 首页授权
      this.sylists = []
      // 角色状态
      this.arr1 = []
      // 人员状态
      this.arr2 = []
      // 刷新列表
      this.getTreeList()
    },
    // 获取树
    async getTreeList() {
      this.loading = true
      let res = await service.yhqx.queryByDwbmYhqx({
        dwbm: this.Tdwbm,
        keyWord: ''
      })
      if (res.code == 0) {
        this.loading = false
        this.yhqlLists = JSON.parse(JSON.stringify(res.data))
        this.yhqlListsFilter = JSON.parse(JSON.stringify(res.data)) //用于前端筛选
        if (this.yhqlLists[0].children.length) {
          this.activeKey[0] = this.yhqlLists[0].children[0].id + '' //默认展开
        } else {
          this.activeKey[0] = ''
        }

        if (this.qingKongFlag) {
          this.onDwSearch()
        }
        // 判断是否从组织机构点击授权节点过来
        if (this.$route.query.id && this.flag) {
          this.onDwSearch2(this.$route.query.id)
        }
      }
    },
    // 复选框选中组件节点变化
    clickCheckZj(checkedKeys, e) {
      this.data = []
      this.changCheck([e.node.dataRef], e.checked)
      this.fn1(this.addZjTree)
      this.CheckedKeysZj = checkedKeys
    },
    // 复选框选中功能节点变化
    clickCheckGn(checkedKeys, e) {
      // 渲染右边的lists
      this.data = []
      // 改变节点下的所有check状态
      this.changCheck([e.node.dataRef], e.checked)
      // 获取右边的数据
      this.fn1(this.addGnTree)
      this.defaultCheckedKeys = checkedKeys
    },
    // 移除授权
    moveSq() {
      if (this.activeTabKey == '1') {
        this.moveSqGnApi()
      } else if (this.activeTabKey == '2') {
        this.moveSqSyApi()
      }
    },
    // 功能授权移出授权Api
    moveSqGnApi() {
      if (this.selectedRows.length <= 0) {
        this.$message.warning('请选择需要移除的功能授权')
        return
      }

      this.$confirm('此操作将移除授权, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          let data = null
          switch (this.sqdxLists[0].level) {
            case '3':
              data = {
                dwbm: this.Tdwbm,
                gnList: this.selectedRows.map(item => item.gnbm),
                jsList: this.sqdxLists.map(item => {
                  return {
                    bmbm: item.params.bmbm,
                    dwbm: item.params.dwbm,
                    jsbm: item.params.jsbm
                  }
                })
              }
              service.yhqx
                .deleteJsgnfp({
                  ...data,
                  zhxgrbm: this.personInfo.rybm,
                  zhxgrmc: this.personInfo.mc
                })
                .then(res => {
                  if (res.code == 0) {
                    res.data && this.CHANGEINFO(res.data)
                    this.$message.success('移除成功')
                  }
                  this.getRoleTable()
                })
              break
            case '4':
              data = {
                dwbm: this.Tdwbm,
                gnList: this.selectedRows.map(item => item.gnbm),
                ryList: this.sqdxLists.map(item => {
                  return {
                    rybm: item.params.rybm,
                    zzdwbm: item.params.zzdwbm,
                    bmbm: item.params.bmbm
                  }
                })
              }
              service.yhqx
                .deleteRygnfp({
                  ...data,
                  zhxgrbm: this.personInfo.rybm,
                  zhxgrmc: this.personInfo.mc
                })
                .then(res => {
                  if (res.code == 0) {
                    res.data && this.CHANGEINFO(res.data)
                    this.$message.success('移除成功')
                  }
                  this.getRyTable()
                })
              break
          }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          })
        })
    },
    // 首页授权移出授权Api
    moveSqSyApi() {
      if (this.SYselectedRows.length <= 0) {
        this.$message.warning('请选择需要移出的首页授权')
        return
      }
      this.$confirm('此操作将移除授权, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
          let data = null
          switch (this.sqdxLists[0].level) {
            case '3':
              data = {
                dwbm: this.Tdwbm,
                zjbm: this.SYselectedRows.map(item => item.bm),
                jsList: this.sqdxLists.map(item => {
                  return {
                    bmbm: item.params.bmbm,
                    dwbm: item.params.dwbm,
                    jsbm: item.params.jsbm
                  }
                })
              }
              break
            case '4':
              data = {
                dwbm: this.Tdwbm,
                zjbm: this.SYselectedRows.map(item => item.bm),
                ryList: this.sqdxLists.map(item => {
                  return {
                    rybm: item.params.rybm,
                    zzdwbm: item.params.zzdwbm,
                    bmbm: item.params.bmbm
                  }
                })
              }
              break
          }

          let res = await service.yhqx.deleteryzjpz({
            dwbm: this.Tdwbm,
            zhxgrbm: this.personInfo.rybm,
            zhxgrmc: this.personInfo.mc,
            ...data
          })

          if (res.code == 0) {
            this.$message.success('移除成功')
            if (this.sqdxLists[0].level == '3') {
              this.getRoleSyTable()
            }
            if (this.sqdxLists[0].level == '4') {
              this.getRySyTable()
            }
          }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    async ycsqSytable(text) {
      let data = null
      switch (this.sqdxLists[0].level) {
        case '3':
          data = {
            zjbm: [text.bm],
            jsList: this.sqdxLists.map(item => {
              return {
                bmbm: item.params.bmbm,
                dwbm: item.params.dwbm,
                jsbm: item.params.jsbm
              }
            })
          }
          break
        case '4':
          data = {
            zjbm: [text.bm],
            ryList: this.sqdxLists.map(item => {
              return {
                rybm: item.params.rybm,
                zzdwbm: item.params.zzdwbm,
                bmbm: item.params.bmbm
              }
            })
          }
          break
      }
      let res = await service.yhqx.deleteryzjpz({
        dwbm: this.Tdwbm,
        zhxgrbm: this.personInfo.rybm,
        zhxgrmc: this.personInfo.mc,
        ...data
      })

      if (res.code == 0) {
        this.$message.success('移除成功')
        if (this.sqdxLists[0].level == '3') {
          this.getRoleSyTable()
        }
        if (this.sqdxLists[0].level == '4') {
          this.getRySyTable()
        }
      }
    },
    // 复制功能权限
    async copyGn() {
      if (this.sqdxLists.length != 1) {
        return false
      }
      if (this.activeTabKey == '1') {
        this.dialogheaderGn = '功能授权'
      } else if (this.activeTabKey == '2') {
        this.dialogheaderGn = '组件授权'
      }
      this.arr1Dia = []
      this.arr2Dia = []

      this.copyGnshow = true
      let res = await service.yhqx.queryByDwbmYhqx({
        dwbm: this.Tdwbm
      })
      this.sqdxListsDia = []
      if (res.code == 0) {
        this.yhqlListsDia = JSON.parse(JSON.stringify(res.data))
        this.yhqlListsDiaFilter = JSON.parse(JSON.stringify(res.data))
        this.activeKey1[0] = this.yhqlLists[0].children[0].id + ''
      }
    },
    // 复制功能确定按钮
    copyGnQdan() {
      if (this.sqdxListsDia.length > 0) {
        if (this.activeTabKey == '1') {
          this.copyGnApi()
        } else if (this.activeTabKey == '2') {
          this.copySyApi()
        }
      } else {
        this.$message.warning('请选择授权对象')
      }
    },
    // 复制功能权限
    copyGnApi() {
      let data = {
        fromJsList: [],
        fromRyList: [],
        toJsList: [],
        toRyList: []
      }
      switch (this.sqdxLists[0].level) {
        case '3':
          data.fromJsList = this.sqdxLists.map(item => {
            return {
              bmbm: item.params.bmbm,
              dwbm: item.params.dwbm,
              jsbm: item.params.jsbm
            }
          })
          break
        case '4':
          data.fromRyList = this.sqdxLists.map(item => {
            return {
              bmbm: item.params.bmbm,
              jsbm: item.params.jsbm,
              rybm: item.params.rybm,
              zzdwbm: item.params.zzdwbm
            }
          })
          break
      }
      switch (this.sqdxListsDia[0].level) {
        case '3':
          data.toJsList = this.sqdxListsDia.map(item => {
            return {
              bmbm: item.params.bmbm,
              dwbm: item.params.dwbm,
              jsbm: item.params.jsbm
            }
          })
          break
        case '4':
          data.toRyList = this.sqdxListsDia.map(item => {
            return {
              bmbm: item.params.bmbm,
              jsbm: item.params.jsbm,
              rybm: item.params.rybm,
              zzdwbm: item.params.zzdwbm
            }
          })
          break
      }
      service.yhqx
        .copyGnApi({
          cjrbm: this.personInfo.rybm,
          cjrmc: this.personInfo.mc,
          ...data
        })
        .then(res => {
          if (res.code == 0) {
            this.$message.success('复制成功')
            this.copyGnshow = false
          }
        })
    },
    // 复制首页授权权限
    copySyApi() {
      let data = {
        fromJs: {},
        fromRy: {},
        toJsList: [],
        toRyList: []
      }
      switch (this.sqdxLists[0].level) {
        case '3':
          data.fromJs = this.sqdxLists[0].params
          break
        case '4':
          data.fromRy = this.sqdxLists[0].params
          break
      }
      switch (this.sqdxListsDia[0].level) {
        case '3':
          data.toJsList = this.sqdxListsDia.map(item => {
            return {
              bmbm: item.params.bmbm,
              dwbm: item.params.dwbm,
              jsbm: item.params.jsbm
            }
          })
          break
        case '4':
          data.toRyList = this.sqdxListsDia.map(item => {
            return {
              bmbm: item.params.bmbm,
              jsbm: item.params.jsbm,
              rybm: item.params.rybm,
              zzdwbm: item.params.zzdwbm
            }
          })
          break
      }
      service.yhqx
        .copyzjdy({
          cjrbm: this.personInfo.rybm,
          cjrmc: this.personInfo.mc,
          ...data
        })
        .then(res => {
          if (res.code == 0) {
            this.$message.success('复制成功')
            this.copyGnshow = false
          }
        })
    },

    // 添加功能
    addGn() {
      if (this.sqdxLists.length <= 0) {
        return false
      }
      this.data = []
      this.selectIds = []
      this.showAdd = true
      this.getAddTreeList()
    },
    // 添加功能确定按钮
    addGnQdan() {
      let gnListArr = this.defaultCheckedKeys.filter(item => {
        return item.length == 10
      })
      if (gnListArr.length == 0) {
        this.$message.warning('请选择添加的功能')
        return
      }
      let data = null
      switch (this.sqdxLists[0].level) {
        case '3':
          data = {
            dwbm: this.Tdwbm,
            gnList: gnListArr,
            jsList: this.sqdxLists.map(item => {
              return item.params
            }),
            cjrbm: this.personInfo.rybm,
            cjrmc: this.personInfo.mc
          }
          service.yhqx.addRoleGnfp(data).then(res => {
            if (res.code == 0) {
              this.$message.success('添加成功')
              this.showAdd = false
              res.data && this.CHANGEINFO(res.data)
              // 刷新列表
              this.getRoleTable()
            }
          })
          break
        case '4':
          data = {
            dwbm: this.Tdwbm,
            gnList: gnListArr,
            ryList: this.sqdxLists.map(item => {
              return {
                rybm: item.params.rybm,
                zzdwbm: item.params.zzdwbm,
                bmbm: item.params.bmbm
              }
            })
          }
          service.yhqx
            .addRyGnfp({
              ...data,
              cjrbm: this.personInfo.rybm,
              cjrmc: this.personInfo.mc
            })
            .then(res => {
              if (res.code == 0) {
                this.$message.success('添加成功')
                this.getRyTable()
                res.data && this.CHANGEINFO(res.data)
                this.showAdd = false
                this.selectIds = []
              }
            })
          break
      }
    },
    // 获取添加功能的树
    async getAddTreeList() {
      let data = {
        dwbm: this.Tdwbm,
        jsList: [],
        ryList: []
      }

      if (this.sqdxLists[0].level == 3) {
        data.jsList = this.sqdxLists.map(item => {
          return {
            bmbm: item.params.bmbm,
            jsbm: item.params.jsbm,
            dwbm: item.params.dwbm
          }
        })
      }

      if (this.sqdxLists[0].level == 4) {
        data.ryList = this.sqdxLists.map(item => {
          return {
            rybm: item.params.rybm,
            zzdwbm: item.params.zzdwbm,
            bmbm: item.params.bmbm
          }
        })
      }

      let res = await service.yhqx.queryByDw(data)
      if (res.code == 0) {
        this.addGnTree = JSON.parse(JSON.stringify(res.data))
        this.addGnTree1 = JSON.parse(JSON.stringify(res.data))
        // 筛选选中的节点
        this.fn(this.addGnTree)
        this.defaultCheckedKeys = this.selectIds.map(item => item.bm)
        this.data = this.selectIds.map(item => {
          return { gnfl: item.gn, gnmc: item.mc }
        })
      }
    },
    // 点击角色获取功能授权table表格
    getRoleTable() {
      this.GNselectedRowKeys = []
      let data = {
        dwbm: this.Tdwbm,
        roleList: this.sqdxLists.map(item => {
          return {
            bmbm: item.params.bmbm,
            jsbm: item.params.jsbm
          }
        })
      }
      service.yhqx.queryByJs(data).then(res => {
        if (res.code == 0) {
          this.lists = res.data
          this.lists1 = res.data
        }
      })
    },
    // 点击人员获取功能授权table表格
    getRyTable() {
      let data = {
        dwbm: this.Tdwbm,
        ryList: this.sqdxLists.map(item => {
          return {
            rybm: item.params.rybm,
            zzdwbm: item.params.zzdwbm,
            bmbm: item.params.bmbm
          }
        })
      }
      service.yhqx.queryByRy(data).then(res => {
        if (res.code == 0) {
          this.lists = res.data
          this.lists1 = res.data
          // this.$message.success("查询人员权限成功");
        }
      })
    },

    // 点击角色获取首页授权table表格
    getRoleSyTable() {
      this.SYselectedRowKeys = []
      let data = {
        dwbm: this.Tdwbm,
        jsList: this.sqdxLists.map(item => {
          return {
            bmbm: item.params.bmbm,
            jsbm: item.params.jsbm,
            dwbm: item.params.dwbm
          }
        })
      }
      service.yhqx.queryByRyOrJs(data).then(res => {
        if (res.code == 0) {
          this.sylists = res.data
          // this.lists1 = res.data.data;
          // this.$message.success("查询首页角色权限成功");
        }
      })
    },

    // 点击人员获取首页授权table表格
    getRySyTable() {
      let data = {
        dwbm: this.Tdwbm,
        ryList: this.sqdxLists.map(item => {
          return {
            rybm: item.params.rybm,
            zzdwbm: item.params.zzdwbm,
            bmbm: item.params.bmbm
          }
        })
      }
      service.yhqx.queryByRyOrJs(data).then(res => {
        if (res.code == 0) {
          this.sylists = res.data
        }
      })
    },
    // 添加组件
    addZj() {
      if (this.sqdxLists.length <= 0) {
        return false
      }
      this.data = []
      this.selectIds = []
      this.showAddZj = true
      this.getAddZjTreeList()
    },

    // 首页授权 获取添加组件的树
    async getAddZjTreeList() {
      let data = {
        dwbm: this.Tdwbm,
        jsList: [],
        ryList: []
      }

      if (this.sqdxLists[0].level == 3) {
        data.jsList = this.sqdxLists.map(item => {
          return {
            bmbm: item.params.bmbm,
            jsbm: item.params.jsbm,
            dwbm: item.params.dwbm
          }
        })
      }

      if (this.sqdxLists[0].level == 4) {
        data.ryList = this.sqdxLists.map(item => {
          return {
            rybm: item.params.rybm,
            zzdwbm: item.params.zzdwbm,
            bmbm: item.params.bmbm
          }
        })
      }

      let res = await service.yhqx.queryByDwzjdy(data)
      if (res.code == 0) {
        this.addZjTree = JSON.parse(JSON.stringify(res.data))
        // 筛选选中的节点
        this.fn(this.addZjTree)
        this.CheckedKeysZj = this.selectIds.map(item => item.bm)
        this.data = this.selectIds.map(item => {
          return { gnfl: item.gn, gnmc: item.mc }
        })
      }
    },

    // 添加组件确定按钮
    addZjQdan() {
      let zjListArr = this.CheckedKeysZj.filter(item => item.length == 10)
      if (zjListArr.length == 0) {
        this.$message.warning('请选择需要添加的功能')
        return
      }
      let data = null
      switch (this.sqdxLists[0].level) {
        case '3':
          data = {
            zjList: zjListArr,
            jsList: this.sqdxLists.map(item => {
              return item.params
            }),
            cjrbm: this.personInfo.rybm,
            cjrmc: this.personInfo.mc
          }
          service.yhqx.addjszjpz(data).then(res => {
            if (res.code == 0) {
              this.$message.success('添加成功')
              this.getRoleSyTable()
              this.showAddZj = false
              // 刷新列表
            }
          })
          break
        case '4':
          data = {
            dwbm: this.Tdwbm,
            cjrbm: this.personInfo.rybm,
            cjrmc: this.personInfo.mc,
            zjList: zjListArr,
            ryList: this.sqdxLists.map(item => {
              return {
                rybm: item.params.rybm,
                zzdwbm: item.params.zzdwbm,
                bmbm: item.params.bmbm
              }
            })
          }
          service.yhqx.addryzjpz(data).then(res => {
            if (res.code == 0) {
              this.$message.success('添加成功1')
              this.showAddZj = false
              this.getRySyTable()
              this.selectIds = []
            }
          })
          break
      }
    },
    // changebjqxDia() {
    //   this.$nextTick(() => {
    //     this.bjqxDia = false;
    //     console.log(this);
    //   });
    // },
    // 编辑权限
    bjqxBtn(text) {
      console.log(text, this.sqdxLists)
      sessionStorage.flbm = text.flbm || ''
      this.bjqxDia = true
      this.qxbjqLiaContent = text
      if (
        this.qxbjqLiaContent &&
        this.qxbjqLiaContent.qxbjqdz.indexOf('http') != -1
      ) {
        return
      }
      let data = {}
      switch (this.sqdxLists[0].level) {
        case '3':
          data = {
            gnbm: text.gnbm,
            jsList: this.sqdxLists.map(item => {
              return item.params
            })
          }
          break
        case '4':
          data = {
            gnbm: text.gnbm,
            ryList: this.sqdxLists.map(item => {
              return {
                rybm: item.params.rybm,
                zzdwbm: item.params.zzdwbm,
                bmbm: item.params.bmbm
              }
            })
          }
          break
      }
      data.lx = text.flmc === '业务报表' ? 1 : 2

      if (text.gnmc === '数据反查') data.lx = 3

      service.gnzj.getGncs(data).then(res => {
        this.DynamicComponent = () => import(`@/views${text.qxbjqdz}.vue`)
        if (res.code == 0) {
          this.CHANGEMIDETYPE(data.lx)
          localStorage.setItem('HQGNCS', JSON.stringify(res.data))
          delete data.gnbm
          localStorage.setItem('HQGNCS_PARAMS', JSON.stringify(data))
        }
      })
    },
    // 递归筛选选中的权限
    fn(data) {
      for (let item of data) {
        if (item.check) {
          this.selectIds.push(item)
        }
        if (item.children.length > 0) {
          this.fn(item.children)
        }
      }
    },
    getChidlren(args, key) {
      var hasFound = false, // 表示是否有找到id值
        result = null
      var fn = function (data) {
        if (Array.isArray(data) && !hasFound) {
          // 判断是否是数组并且没有的情况下，
          data.forEach(item => {
            if (item.bm === key) {
              // 数据循环每个子项，并且判断子项下边是否有id值
              result = item // 返回的结果等于每一项
              hasFound = true // 并且找到id值
            } else if (item.children) {
              fn(item.children) // 递归调用下边的子项
            }
          })
        }
      }
      fn(args) // 调用一下
      return result
    },
    // 改变节点得check
    changCheck(data, e) {
      for (let item of data) {
        item.check = e
        if (item.children && item.children.length > 0) {
          this.changCheck(item.children, e)
        }
      }
    },
    // 获取展示得数据 递归到最后一层
    fn1(data) {
      for (let item of data) {
        if (item.children && item.children.length > 0) {
          this.fn1(item.children)
        } else if (item.check && item.level != 1) {
          this.data.push({ gnfl: item.gn, gnmc: item.mc })
        }
      }
    }
  },
  computed: {
    ...logininfo.mapState(['personInfo']),
    ...yhqxinfo.mapState(['nodeMessegeVuex']),
    GNrowSelection() {
      return {
        getCheckboxProps: record => ({
          props: {
            disabled: record.disabled,
            name: record.disabled + ''
          }
        })
      }
    },
    SYrowSelection() {
      return {
        getCheckboxProps: record => ({
          props: {
            disabled: record.disabled,
            name: record.disabled + ''
          }
        })
      }
    }
  },
  components: { newTreeSelect }
}
</script>

<style lang="less" scoped>
@import "./css/variableLess.less";
.main-container {
  width: 100%;
  min-height: 800px;
  float: left;
  background-color: #eaeeef !important;
  display: flex;
  justify-content: center;

  .box-container {
    width: 1540px;
    margin: 25px 0;
    background-color: #fff;
    .tabsHeader {
      /deep/.ant-tabs-nav {
        font-size: 16px;
      }
      /deep/ .ant-tabs-tab-active::after {
        left: 8% !important;
        top: 93% !important;
      }
    }
    .yhqx-left {
      float: left;
      width: 448px;
      height: 100%;
      background-color: #fff;
      border-radius: 5px;
    }
    .right {
      float: right;
      height: 100%;
      width: calc(100% - 460px);

      .top {
        height: 120px;
        background-color: #fff;
        border-radius: 5px;
      }
      .bottom {
        margin-top: 10px;
        height: calc(100% - 130px);
        background-color: #fff;
        border-radius: 5px;
      }
    }
  }
}
/deep/ .ant-tabs-bar {
  margin: 0;
}
/deep/ .ant-tabs-tabpane {
  padding: 16px;
}
/deep/ .ant-tabs {
  height: 100%;
}
/deep/ .ant-tabs-content {
  height: calc(100% - 40px);
}
// /deep/ .ant-tabs-tabpane-inactive {
//   height: 100%;
// }
/deep/ .tab-box,
/deep/ .ant-tabs {
  height: 100%;
}

/deep/ .ant-input:focus {
  box-shadow: none;
}
/deep/ .collapse-item {
  font-size: 16px;
  .panel-title {
    height: unset;
    div {
      display: inline-block;
      box-sizing: border-box;
      padding: 0px 18px;
      text-align: center;
      line-height: 28px;
      margin-bottom: 10px;
      height: 28px !important;
      font-size: 14px;
      border-radius: 3px;
      min-width: 78px;
    }
  }
  //禁用
  .panel-title2 {
    div {
      display: inline-block;
      box-sizing: border-box;
      padding: 0px 18px;
      margin-bottom: 10px;
      font-size: 14px;
      text-align: center;
      height: 28px !important;
      line-height: 28px;
      color: @btnColorNotAllow;
      background: @btnBgColor;
      border-radius: 3px;
      cursor: not-allowed !important;
      min-width: 78px;
    }
  }
  // 选中状态
  .panel-title1 {
    div {
      position: relative;
      display: inline-block;
      // min-width: 60px;
      padding: 0px 18px;
      text-align: center;
      border: 1px solid #05b75d;
      box-sizing: border-box;
      background-color: #fff;
      height: 28px;
      line-height: 28px;
      color: @fontColor;
      font-size: 14px;
      border-radius: 3px;
      text-align: center;
      min-width: 78px;
    }
    div:after {
      content: "";
      height: 0;
      border: solid transparent;
      position: absolute;
      border-width: 9px;
      border-top-color: #05b75d;
      border-right-color: #05b75d;
      top: 0px;
      right: 0px;
    }
    div::before {
      content: "";
      width: 6px;
      height: 9px;
      position: absolute;
      right: 2px;
      bottom: 20px;
      z-index: 1;
      border: 2px solid #fff;
      border-top-color: transparent;
      border-left-color: transparent;
      transform: rotate(45deg);
    }
  }
}

/deep/
  .ant-collapse
  > .ant-collapse-item
  > .ant-collapse-header
  .ant-collapse-arrow {
  right: -378px;
  left: 0;
}

.ant-collapse > .ant-collapse-item > .ant-collapse-header {
  padding-left: 20px;
}
.box {
  margin-bottom: 10px;
}
.box:nth-last-child(1) {
  margin-bottom: 0;
}

.yhqx-dialog {
  /deep/ .ant-modal {
    width: 1150px !important;
  }
  .ant-tabs-tabpane-active {
    overflow: auto !important;
  }
  .dialogheader {
    height: 35px;
    background-color: #cbe2ff;
    font-size: 16px;
    font-weight: 700;
    line-height: 35px;
    padding-left: 10px;
    color: #0090ff;
  }
  .dialogcontent {
    padding: 10px;
    display: flex;
    .left {
      padding: 10px;
      box-sizing: border-box;
      width: 325px;
      height: 600px;
      border: 1px solid @borderColor-h;
      margin-right: 10px;
    }
    .right {
      width: calc(100% - 335px);
      height: 600px;
    }
  }
  .dialog {
    border: 1px solid @borderColor-h;
  }
}
.yhqx-dialog2 {
  /deep/ .ant-modal {
    width: 1150px !important;
  }
  .dialogheader {
    height: 35px;
    background-color: #cbe2ff;
    font-size: 16px;
    font-weight: 700;
    line-height: 35px;
    padding-left: 10px;
    color: #0090ff;
  }
  .dialogcontent {
    padding: 10px;
    display: flex;
    .left {
      padding: 10px;
      box-sizing: border-box;
      width: calc(50% - 108px);
      height: 600px;
      border: 1px solid @borderColor-h;
      margin-right: 10px;
    }
    .right {
      width: calc(50% + 98px);
      height: 600px;
    }
  }
  .dialog {
    border: 1px solid @borderColor-h;
  }
}
// .ant-tabs-tabpane-inactive {
//   height: 100%;
// }
.ant-collapse {
  height: calc(100% - 45px);
  overflow-y: auto;
  overflow-x: hidden;
}
.left {
  /deep/ .ant-tree {
    height: calc(100% - 34px);
    overflow-y: auto;
    overflow-x: hidden;
  }
}
/deep/ .ant-checkbox-wrapper-disabled {
  .ant-checkbox-disabled {
    .ant-checkbox-inner {
      background-color: @borderColor-h;
    }
  }
}
.disabled-btn {
  color: @btnColorNotAllow;
  background-color: #f5f5f5;
  cursor: not-allowed;
}

/deep/ .ant-tabs .ant-tabs-top-content,
.ant-tabs .ant-tabs-bottom-content {
  height: calc(100% - 40px) !important;
  // background: gold;
  .ant-tabs-tabpane-active {
    height: 100%;
  }
  // 滚动条的问题
  // .ant-tabs-tabpane-inactive {
  //   height: 100%;
  // }
  .ant-table-wrapper {
    height: 100%;
    .ant-spin-nested-loading {
      height: 100%;
      .ant-spin-container {
        height: 100%;
        .ant-table {
          height: calc(100% - 40px);
          overflow: auto;
        }
      }
    }
  }
}

.tableItem {
  margin-top: 20px;
}
.tableItem:first-child {
  margin-top: 0;
}
/deep/.ant-modal-body .ant-tabs-nav .ant-tabs-tab {
  padding: 12px 16px;
}
.ant-collapse {
  background-color: #fff;
}
</style>
